//
//  SharePerenceHelper.m
//  ModifyMetroDemo
//
//  Created by Marcus on 2020/3/9.
//  Copyright © 2020 Facebook. All rights reserved.
//

#import "SharePerenceHelper.h"

static SharePerenceHelper *instance;

@implementation SharePerenceHelper

- (id)init {
  if ((self = [super init])) {
    // other
  }
  return self;
}

+ (SharePerenceHelper*)instance{
  @synchronized(self) {
    if (!instance) {
      instance = [[self alloc] init];
    }
  }
  return instance;
}

- (void) saveReactNativeBusinessInfo:(RNBusinessInfo*) businessInfo{
  NSUserDefaults *userDef = [NSUserDefaults standardUserDefaults];
   NSData *data = [NSKeyedArchiver archivedDataWithRootObject:businessInfo];
  [userDef setObject:data forKey:@"ReactNativeBusinessInfo"];
  [userDef synchronize];
};

- (RNBusinessInfo*)getReactNativeBusinessInfo{
  NSUserDefaults *userDef = [NSUserDefaults standardUserDefaults];
  NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:@"ReactNativeBusinessInfo"];
  RNBusinessInfo *model = [NSKeyedUnarchiver unarchiveObjectWithData:data];
  return model;
};

@end
